package com.igeek.shop.web.shouye;

import java.io.IOException;
import java.util.List;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.igeek.shop.entity.Product;
import com.igeek.shop.service.ProductService;

public class IndexServlet2 implements Filter {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
	ProductService service = new ProductService();
		
		//获取热门商品--list<product>
		List<Product> hotProductList = service.findHotProductList();
		//获取最新商品--list<product>
		List<Product> newProductList = service.findNewProductList();
		
		req.setAttribute("hotProductList", hotProductList);
		req.setAttribute("newProductList", newProductList);
		
		chain.doFilter(req, resp);  //当请求放行之后 。
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub
		
	}

	
	
}
